package com.zyp;


import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
/**
 * @author zhangyanping
 */
public class Server {
    public static void main(String[] args) {
        try {
            ServerSocket serverSocket = new ServerSocket(9001);
            while (true){
                Socket socket =  serverSocket.accept();
                System.out.println("有人连上了服务器");

                byte [] msg = new byte[1024];
                socket.getInputStream().read(msg);
                System.out.println("收到消息："+new String(msg));
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
